
<!DECTYPE html>
<html>
<head>
    <meta charset=‘utf-8’>
    <title>onwheel-test</title>
    <style>
        .out {
            width:500px;
            height:500px;
            box-shadow: 0 0 1px 1px;
            overflow:auto;
        }

        .inside {
            width:100px;
            height:100px;
            background-color:gray;
            overflow:auto;
        }
    </style>
</head>
<body>
<div id='out' class="out">
    <div id='inside' class="inside">
    </div>
</div>

<script>
    function getObj(val, unit = 1) {
        const dateTime = new Date(val * unit)
        const year = dateTime.getFullYear()
        const month = dateTime.getMonth() + 1
        const date = dateTime.getDate()
        const hours = dateTime.getHours()
        const minutes = dateTime.getMinutes()
        const seconds = dateTime.getSeconds()
        return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
        // return {
        //     year: date.getFullYear(),
        //     month: date.getMonth() + 1,
        //     date: date.getDate(),
        //     hour: date.getHours(),
        //     minute: date.getMinutes(),
        //     seconds: date.getSeconds()
        // }
    }

    function getObj2(val, unit = 1) {
        let dateTime = val
        if (!(dateTime instanceof Date)) {
            dateTime = new Date(val / 1000000)
        }
        const year = dateTime.getFullYear()
        const month = dateTime.getMonth() + 1
        const date = dateTime.getDate()
        const hours = dateTime.getHours()
        const minutes = dateTime.getMinutes()
        const seconds = dateTime.getSeconds()
        return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
    }

    function getObj3(val, unit = 1) {
        let dateTime = new Date(val)
        const year = dateTime.getFullYear()
        const month = dateTime.getMonth() + 1
        const date = dateTime.getDate()
        const hours = dateTime.getHours()
        const minutes = dateTime.getMinutes()
        const seconds = dateTime.getSeconds()
        return `${year}-${month}-${date} ${hours}:${minutes}:${seconds}`
    }

    function console1() {
        // var res = {"status":"success","data":{"resultType":"matrix","result":[{"metric":{},"values":[[1637712000,"15"],[1637798400,"5"],[1637884800,"30"],[1638230400,"7"],[1638316800,"72"]]}],"stats":{"summary":{"bytesProcessedPerSecond":23382080,"linesProcessedPerSecond":36400,"totalBytesProcessed":2040125,"totalLinesProcessed":3176,"execTime":0.087251644},"store":{"totalChunksRef":282,"totalChunksDownloaded":282,"chunksDownloadTime":0.545273684,"headChunkBytes":0,"headChunkLines":0,"decompressedBytes":2040125,"decompressedLines":3176,"compressedBytes":582922,"totalDuplicates":87},"ingester":{"totalReached":0,"totalChunksMatched":0,"totalBatches":0,"totalLinesSent":0,"headChunkBytes":0,"headChunkLines":0,"decompressedBytes":0,"decompressedLines":0,"compressedBytes":0,"totalDuplicates":0}}}}
        var res = {"status":"success","data":{"resultType":"matrix","result":[{"metric":{},"values":[[1637625600,"6"],[1637712000,"15"],[1637798400,"5"],[1637884800,"30"],[1638230400,"7"],[1638316800,"72"],[1638403200,"30"],[1638489600,"10"]]}],"stats":{"summary":{"bytesProcessedPerSecond":40456468,"linesProcessedPerSecond":64469,"totalBytesProcessed":3187822,"totalLinesProcessed":5080,"execTime":0.078796348},"store":{"totalChunksRef":480,"totalChunksDownloaded":480,"chunksDownloadTime":0.133704473,"headChunkBytes":0,"headChunkLines":0,"decompressedBytes":3187822,"decompressedLines":5080,"compressedBytes":956177,"totalDuplicates":101},"ingester":{"totalReached":2,"totalChunksMatched":24,"totalBatches":0,"totalLinesSent":0,"headChunkBytes":0,"headChunkLines":0,"decompressedBytes":0,"decompressedLines":0,"compressedBytes":0,"totalDuplicates":0}}}}
        const values = res.data.result[0].values
        values.forEach((arr) => {
            console.log(getObj(arr[0]), arr[1])
        })
    }


    // console.log(getObj3('2017-11-16T05:23:20.000Z'))
    // console.log(getObj(1638230400, 1000))
    console.log(getObj2(1640016000000000000))
    // console.log('2021-12-01 00:00:00')
    // console.log(new Date('2021-02-01 00:00:00').getTime())
    // console.log(new Date('2021-2-01 00:00:00').getTime())
    // console.log(new Date('2021-02-01 00:00:00'))
    // console.log(new Date('2021-2-01 00:00:00'))
    // console.log(new Date('2021-02-01'))
    // console.log(new Date('2021-2-01'))
</script>
</body>
</html>